<?php

// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------

namespace Portal\Controller;

use Common\Controller\HomeBaseController;

/**
 * 女性不孕
 */
class FemaleController extends HomeBaseController {

    //医生列表面
    public function index() {
        $this->assign('select', '6');
        $terms_info = D("Terms")->where(array("term_id" => 6))->find();
        $this->assign("terms_info", $terms_info);
        //下面分类
        $terms_list = D("Terms")->where(array('parent' => 6))->select();
        $this->assign("terms_list", $terms_list);
        $this->display();
    }

    /**
     * 列表显示
     */
    public function pshow() {
        $this->assign('select', '6');
        $id = I("id");
        $this->assign("id",$id);
        $terms_list = D("Terms")->where(array('parent' => $id))->select();
        if (empty($terms_list)) {
           $count= D("TermRelationships")->alias("tr")->join("__POSTS__ p ON tr.object_id=p.id")->where(array('tr.term_id'=>$id))->count();
$page = $this->page($count, 10);            
//获取信息列表
            $findlist= D("TermRelationships")->alias("tr")->join("__POSTS__ p ON tr.object_id=p.id")->where(array('tr.term_id'=>$id))->limit($page->firstRow . ',' . $page->listRows)->order("p.post_modified desc")->select();
            $this->assign("findlist",$findlist);
            
            $this->assign("Page", $page->show());
            $this->display();
        } else {
            $this->assign("terms_list", $terms_list);
            $terms_info = D("Terms")->where(array("term_id" => $id))->find();
            $this->assign("terms_info", $terms_info);
            $this->display("index");
        }
    }

}
